package routerServer

import (
	"github.com/gin-gonic/gin"
	"io"
)

var (
	engine *gin.Engine
	server *routerServer
	router *routerHandler
	auth   *authHandler
	topic  *topicHandler
)

func init() {
	// 禁止打印日志：将日志输出，重定向到一个空的位置
	gin.SetMode(gin.DebugMode)
	gin.DefaultWriter = io.MultiWriter()

	engine = gin.Default()

	// 启动redis消息接收
	topic = &topicHandler{}

	router = &routerHandler{}
	router.router = make(map[string]interface{})
}

func StartServer(handler ITopicHandler) {
	go server.startServer()

	topic.handler = handler
	go topic.subscribe()
}
